import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *

testCase = "DBshop013_分类编辑"
# 1.点击添加分类按钮，分类名称“商品分类测试”,分类排序输入1。
firefox = openBrowser(urlAdmin)
DBshopLoginAdmin(firefox)
DBshopEnterMenu3(firefox, "商品管理", "管理分类","商品分类")
firefox.find_element_by_partial_link_text("添加分类").click()
firefox.find_element_by_id("class_name").send_keys(goodsClassName)
# 2.点击“保存分类”按钮”。
firefox.find_element_by_xpath("//button").click()
# 3.点击“商品分类测试”后方的分类编辑链接,进入商品分类编辑页面
# firefox.find_element_by_xpath('//td[contains(.,"%s")]/following-sibling::td[4]/a[2]'%goodsClassName).click()
# firefox.find_element_by_id('class_sort').clear()
# firefox.find_element_by_id('class_sort').send_keys('4')
# firefox.find_element_by_xpath('(//button)[2]').click()
# import time
# time.sleep(2)
time.sleep(15)
firefox.find_element_by_xpath('//td[contains(.,"%s")]/following-sibling::td[4]/a[2]'%goodsClassName).click()
firefox.find_element_by_id('class_sort').clear()
firefox.find_element_by_id('class_sort').send_keys('4')
firefox.find_element_by_xpath('(//button)[2]').click()
import time
time.sleep(2)
#断言
shijizhi=firefox.find_element_by_xpath('//td[contains(.,"%s")]/following-sibling::td[2]/input'%goodsClassName).get_attribute('value')
if shijizhi=="4":
    writeLog("%s 测试通过"%testCase)
else:
    writeLog("%s 测试失败" % testCase)

firefox.quit()
